package com.kinggm.service.observer.impl;

import com.kinggm.service.observer.DisplayElement;
import com.kinggm.service.observer.Observer;
import com.kinggm.service.observer.Subject;

public class StatisticsDisplay implements Observer, DisplayElement {

    private float temperature;
    private float humidity;
    private float pressure;
    private Subject subject;


    public StatisticsDisplay(Subject subject) {
        subject.registerObserver(this);
        this.subject = subject;
    }


    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        display();
    }

    @Override
    public void display() {
        System.out.println("StatisticsDisplay  \n 温度：" + temperature + "湿度：" + humidity + "气压：" + pressure);
    }


}
